package com.itheima.fanshe;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Arrays;

public class Demo03 {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
        Class clazz = Class.forName("com.itheima.fanshe.Singer");
        Object o = clazz.getDeclaredConstructor().newInstance();
        Method dance = clazz.getMethod("dance", String.class);
        dance.invoke(o,"大碗宽面");
        System.out.println(dance);
        Method[] methods = clazz.getMethods();
        System.out.println(Arrays.toString(methods));


        Method sing = clazz.getDeclaredMethod("sing");
        System.out.println(sing);
    sing.setAccessible(true);
        Object invoke1 = sing.invoke(o);
        System.out.println(invoke1);
        Method[] declaredMethods = clazz.getDeclaredMethods();
        System.out.println(Arrays.toString(declaredMethods));


        Method getNumber = clazz.getMethod("getNumber", int.class, int.class);
        Object invoke = getNumber.invoke(o, 10, 20);
        System.out.println(invoke);
    }
}
